<?php
if (!defined('APP_PATH')) {
	define('APP_PATH', $_SERVER['DOCUMENT_ROOT']."/bdACPA");
}
require_once(APP_PATH.'/required.php');

$idPuce = intval($_REQUEST["idPuce"]);
//set content type and xml tag
header("Content-type:text/xml");
echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
$personne = null;
$out = "";


print("<rows>");
$out .=" <head>   	";

$out .="  	<column type='ro' width='40' sort='str'>Chr.</column>";
$out .="  	<column type='ro' width='50' sort='int'>Nb copies</column>";
$out .="  	<column type='ro' width='60' sort='na'>Log2R</column>";
$out .="  	<column type='ro' width='60' sort='na'>Taille (kb)</column>";
$out .="  	<column type='ro' width='100' sort='na'>Debut</column>";
$out .="  	<column type='ro' width='100' sort='na'>Fin</column>";
$out .="  	<column type='co' width='150' sort='int' id='verifie'>Vérifié?";
$verifs = $TYPEVERIF_DAO->rechercher_type_verif(null);
foreach ($verifs as $verif){
	$out .="   		<option value='".$verif->idtypeverif."'>".$verif->libelle."</option>";
}
$out .=" 	</column>	";
$out .="  	<column type='co' width='150' sort='int' id='methodeverification'>Méthode";
$methodeverifs = $TYPEMETHODEVERIF_DAO->rechercher_type_methode_verif(null);

$out .="   		<option value='0'>pas de vérification</option>";

foreach ($methodeverifs as $methodeverif){
	$out .="   		<option value='".$methodeverif->idtypemethodeverif."'>".$methodeverif->libelle."</option>";
}
$out .=" 	</column>	";
$out .="  	<column type='co' width='150' sort='int' id='herite'>Hérité?";
$herites = $TYPEHERITE_DAO->rechercher_type_herite(null);
foreach ($herites as $herite){
	$out .="   		<option value='".$herite->idtypeherite."'>".$herite->libelle."</option>";
}
$out .=" 	</column>	";
$out .="  	<column type='ro' width='200' sort='na'>Commentaire</column>";
$out .="  	<column type='co' width='150' sort='int' id='classification'>Classification";
$classs = $TYPECLASSIFICATION_DAO->rechercher_type_classification(null);
foreach ($classs as $class){
	$out .="   		<option value='".$class->idtypeclassification."'>".$class->libelle."</option>";
}
$out .=" 	</column>	";
$out .=" </head>";
if ($idPuce != 0){
	$CNVS = $CNV_DAO->recuperer_CNV_par_puce($idPuce);
	if ($CNVS != null){
		foreach ($CNVS as $CNV){
			//$cn_statut = $ALTERATION_DAO->calculeCN_State($CNV["cn_statut"],$CNV["chromosome"],$CNV["sexe"]);
			$out .="<row id='".$CNV->idcnv."' >";
			$out .="<cell>".html_entity_decode(stripcslashes($CNV->chromosome))."</cell>";
			$out .="<cell>".intval(html_entity_decode(stripcslashes($CNV->nbcopie)))."</cell>";
			$out .="<cell>".html_entity_decode(stripcslashes($CNV->log2ratio))."</cell>";
			$out .="<cell>".round((intval($CNV->positionfin)-intval($CNV->positiondebut))/1000,1)."</cell>";
			$out .="<cell>".formatEspace(intval(html_entity_decode(stripcslashes($CNV->positiondebut))),0);
					if ($CNV->sondedebut!= null)
			$out .=" (".html_entity_decode(stripcslashes($CNV->sondedebut)).")";
			$out .="</cell>";
			$out .="<cell>".formatEspace(intval(html_entity_decode(stripcslashes($CNV->positionfin))),0);
			if ($CNV->sondefin!= null)
				$out .=" (".html_entity_decode(stripcslashes($CNV->sondefin)).")";
			$out .="</cell>";
			$out .="<cell>".intval(html_entity_decode(stripcslashes($CNV->verifie)))."</cell>";
			$out .="<cell>".intval(html_entity_decode(stripcslashes($CNV->methodeverification)))."</cell>";
			$out .="<cell>".intval(html_entity_decode(stripcslashes($CNV->herite)))."</cell>";
			$out .="<cell>".html_entity_decode(stripcslashes($CNV->commentaire))."</cell>";
			$out .="<cell>".intval(html_entity_decode(stripcslashes($CNV->classification)))."</cell>";
			$out .="</row>";
		}
	}
}
print($out);
print("</rows>");